<template>
	<view>
		<view class="pay_zhifu_type">
			<view class="head">支付方式</view>
			<radio-group @change="changeCurr">
				<label class="pay_zhifu_item" v-for="(item, index) in items" :key="item.value">
					<view class="pay_zhifu_status_type">
						<text class="iconfont icon" :class="{'icon-weixin':item.value==1,'icon-zhifubao':item.value==2,'icon-yinhangka_mian':item.value==0}"></text>
						<text>{{item.name}}</text>
					</view>
					<view>
						<radio class="withdrawal_status_radio" color="#8615E1" :value="item.value" :checked="item.value == current" />
					</view>
				</label>
			</radio-group>
		</view>
		<view class="totalBtn" @click="submit">去支付</view>
	</view>
</template>

<script>
	import Base64 from 'base-64';
	export default {
		data() {
			return {
				items: [{
					value: '1',
					name: '微信',
					checked: true
				},{
					value: '2',
					name: '支付宝',
					checked: true
				}],
				current: 1,
				// content: '',
				// sig: '',
				mid: 0,
				uid: 0,
			}
		},
		onLoad(option){
			// if (option.q) {
			// 	let scan_url = decodeURIComponent(option.q);
			// 	this.content = this.gup('content', scan_url);
			// 	this.sig = this.gup('sig', scan_url);
			// } else {
			// 	this.content = option.content;
			// 	this.sig = option.sig;
			// }
			// uni.setStorageSync('mid', Base64.decode(this.content));
			// this.mid=Base64.decode(this.content);
			if(option.id){
				this.uid = option.id;
			}
			if(option.mid){
				this.mid = option.mid;
			}
			uni.setStorageSync('mid', this.mid);
			if(!uni.getStorageSync('token')){
				this.getToken();
			}
		},
		methods: {
			submit(){
				if(this.current==1){
					this.$axios('supplierGoods/payCode', 'POST', 'shop', {
						supplier_uid: this.uid
					}).then(res => {
						if (res.data.code == 200) {
							this.$navTo(res.data.data);
							// this.$navNew(res.data.data);
						}
					})
				}else{
					this.$axios('supplierGoods/payCode', 'POST', 'shop', {
						supplier_uid: this.uid
					}).then(res => {
						if (res.data.code == 200) {
							this.$navTo('https://bph5.jinghushi.com/'+res.data.data);
							// this.$navNew(res.data.data);
						}
					})
					// this.$navTo('https://bph5.jinghushi.com?id='+this.uid);
				}
			},
			
			changeCurr(e){
				console.log(e)
				this.current = e.detail.value;
			},
			getToken(){
				uni.login({
					provider: 'weixin',
					success:res=> {
						this.$axios('login/autologin','POST','member',{
							mid: this.mid,
							code: res.code
						}).then(res=>{
							if(res.data.code == 200){
								uni.setStorageSync('token', res.data.data);
								uni.setStorageSync('Jh_recotabshops', 1);
								this.getSharePath();
							}
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	@import '/store/icon.css';
	.pay_zhifu_type{
			background: #fff;
			margin: 0 10rpx;
			padding: 20rpx;
			.pay_zhifu_item{
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 10rpx;
			}
			.pay_zhifu_status_type{
				display: flex;
				align-items: center;
			}
			.pay_zhifu_status_type .icon {
				font-size: 100rpx;
				margin-right: 30rpx;
			}
			.icon-weixin {
				color: #50bb34;
			}
			
			.icon-zhifubao {
				color: #44a9fd;
			}
			.withdrawal_status_radio {
				transform: scale(1.2);
			}
		}

</style>
